package cn.yunyichina.provider.base.service.impl;

import cn.yunyichina.provider.base.dao.AppVersionDao;
import cn.yunyichina.provider.base.entity.AppVersion;
import cn.yunyichina.provider.iface.entity.common.ResponseObject;
import cn.yunyichina.utils.convert.JsonUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * app版本号
 * Created by Administrator on 2016/12/1.
 */
@Service
public class AppVersionServiceImpl {
    @Autowired
    private AppVersionDao dao;

    /**
     * 获取app版本号和更新地址
     * @param data
     * @return
     */
    public ResponseObject getAppVersion(String data) {
        AppVersion wheres = null ;
        if(StringUtils.isNotBlank(data)) {
            wheres = JsonUtils.parseObject(data, AppVersion.class);
        }

        ResponseObject response = new ResponseObject();
        response.setResultCodeAndMessage("0", "调用成功");
        List<AppVersion> list = dao.select(wheres);
        if(list != null && list.size() > 0) {
            response.setResultObject(list.get(0));
        }
        return response;
    }
}
